﻿using Microsoft.EntityFrameworkCore;
using SmartCity.Passport.Domain.Entites;

namespace SmartCity.Passport.API.Infrastructure
{
    public class DataDbContext : DbContext
    {
        public DataDbContext(DbContextOptions options) : base(options)
        {
        }
        /// <summary>
        /// 角色列表
        /// </summary>
        public DbSet<Role> roles { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DbSet<User> users { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DbSet<RoleUser> roleUsers { get; set; }
        /// <summary>
        /// 权限列表
        /// </summary>
        public DbSet<Permission> permissions { get; set; }
        /// <summary>
        /// 角色权限列表
        /// </summary>
        public DbSet<RolePermission> rolePermissions { get; set; }
        public DbSet<Department> Department { get; set; }
        public DbSet<DepartmentUser> DepartmentUser { get; set; }
        /// <summary>
        /// 当模型正在创建时发生
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //强调没有主键的实体
            modelBuilder.Entity<RoleUser>().HasNoKey();
            modelBuilder.Entity<RolePermission>().HasNoKey();
            modelBuilder.Entity<DepartmentUser>().HasNoKey();
        }

    }
}
